package com.campusify.controller;


import com.campusify.compents.ApiResponse;
import com.campusify.compents.PageResult;

import com.campusify.pojo.Taskacceptance;
import com.campusify.service.TaskacceptanceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
/**
 * controller
 * @author Administrator
 *
 */
@RestController
@RequestMapping("/taskAcceptance")
public class TaskacceptanceController {

	@Autowired
	private TaskacceptanceService taskAcceptanceService;
	
	/**
	 * 返回全部列表
	 * @return
	 */
	@RequestMapping("/findAll")
	public List<Taskacceptance> findAll(){			
		return taskAcceptanceService.findAll();
	}
	
	
	/**
	 * 返回全部列表
	 * @return
	 */
	@RequestMapping("/findPage")
	public PageResult  findPage(int page,int rows){			
		return taskAcceptanceService.findPage(page, rows);
	}
	
	/**
	 * 增加
	 * @param taskAcceptance
	 * @return
	 */
	@RequestMapping("/add")
	public ApiResponse add(@RequestBody Taskacceptance taskAcceptance){
		try {
			taskAcceptanceService.add(taskAcceptance);
			return ApiResponse.success(null);
		} catch (Exception e) {
			e.printStackTrace();
			return ApiResponse.failed(null);
		}
	}
	
	/**
	 * 修改
	 * @param taskAcceptance
	 * @return
	 */
	@RequestMapping("/update")
	public ApiResponse update(@RequestBody Taskacceptance taskAcceptance){
		try {
			taskAcceptanceService.update(taskAcceptance);
			return ApiResponse.success(null);
		} catch (Exception e) {
			e.printStackTrace();
			return ApiResponse.failed(null);
		}
	}	
	
	/**
	 * 获取实体
	 * @param id
	 * @return
	 */
	@RequestMapping("/findOne")
	public Taskacceptance findOne(Integer recordID){
		return taskAcceptanceService.findOne(recordID);		
	}
	
	/**
	 * 批量删除
	 * @param ids
	 * @return
	 */
	@RequestMapping("/delete")
	public ApiResponse delete(Integer [] recordIDs){
		try {
			taskAcceptanceService.delete(recordIDs);
			return ApiResponse.success(null); 
		} catch (Exception e) {
			e.printStackTrace();
			return ApiResponse.failed(null);
		}
	}
	
		/**
	 * 查询+分页
	 * @param brand
	 * @param page
	 * @param rows
	 * @return
	 */
	@RequestMapping("/search")
	public PageResult search(@RequestBody Taskacceptance taskAcceptance, int page, int rows  ){
		return taskAcceptanceService.findPage(taskAcceptance, page, rows);		
	}
	
}
